/*
package ilincar.systemcore.ddpush;

import android.os.Handler;

import org.ddpush.im.v1.client.appuser.Message;
import org.ddpush.im.v1.client.appuser.UDPClientBase;
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;

*/
/**
 * Created by ilincar on 2016/12/9.
 *//*


@Deprecated
public class DDPushClient extends UDPClientBase{

    private final String TAG = "DDPushClient";

    private OnDDPushListener ddPushListener;

    public DDPushClient(byte[] uuid, int appid, String serverAddr, int serverPort) throws Exception {
        super(uuid, appid, serverAddr, serverPort);
    }

    @Override
    public boolean hasNetworkConnection() {
        return true;
    }

    @Override
    public void trySystemSleep() {

    }

    @Override
    public void onPushMessage(Message message) {
        if(message == null || message.getData() == null || message.getData().length == 0){
            return;
        }

        if(message.getCmd() == 16){
            // 0x10 通用推送信息
        }else if(message.getCmd() == 17){
            // 0x11 分组推送信息
        }else if(message.getCmd() == 32){
            //自定义推送信息
            String msg = null;
            try {
                msg = new String(message.getData(), 5, message.getContentLength(), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                msg = DDPushUtils.convert(message.getData(), 5, message.getContentLength());
                e.printStackTrace();
            }
            android.os.Message handMsg = android.os.Message.obtain();
            handMsg.what = DDPushUtils.CUSTOM_NOTIFICATION_MESSAGE;
            handMsg.obj = msg;
        }

    }

    public void setDdPushListener(OnDDPushListener ddPushListener) {
        this.ddPushListener = ddPushListener;
    }

    private Handler mHandler = new Handler(){
        @Override
        public void handleMessage(android.os.Message msg) {
            switch (msg.what){
                case DDPushUtils.CUSTOM_NOTIFICATION_MESSAGE:
                    String text = (String) msg.obj;
                    postMessage(text);
                    break;
            }
        }
    };

    private void postMessage(String text){
        if(ddPushListener == null){
            return;
        }
        try {
            String respone = DDPushUtils.getEncodeAndGzip(text);
            JSONObject jsonObject = new JSONObject(respone);
            String code = ""; JSONObject data = null;
            if(jsonObject.has("order")){
                JSONObject order = jsonObject.getJSONObject("order");
                if(order.has("code")){
                    code = order.getString("code");
                    data = order.getJSONObject("data");
                }
            }else{
                if(jsonObject.has("code")){
                    code = jsonObject.getString("code");
                    if(jsonObject.has("data")){
                        data = jsonObject.getJSONObject("data");
                    }
                }
            }

            if(DDPushUtils.DDPUSH_CAR_POSITION.equals(code)){
                //请求当前车机位置
                ddPushListener.onRequestCarPosition();
            }else if(DDPushUtils.DDPUSH_PRENAVIGATION.equals(code)){
                //请求预导航
                ddPushListener.onRequestPrenavigation(data);
            }else if(DDPushUtils.DDPUSH_BIND_DATA.equals(code)){
                //返回车机绑定数据
                ddPushListener.onReceiveBindData(data);
            }else if(DDPushUtils.DDPUSH_OBD_DATA.equals(code)){
                //请求OBD数据
                ddPushListener.onRequestOBDData();
            }else if(DDPushUtils.DDPUSH_TAKE_PHOTO.equals(code)){
                //请求拍照
                ddPushListener.onRequestTakePhoto();
            }else if(DDPushUtils.DDPUSH_WEIXIN_ACCESS.equals(code)){
                //微信接人
                ddPushListener.onRequestWeiXinAccess(data);
            }else if(DDPushUtils.DDPUSH_REQUEST_VIDEO.equals(code)){
                //请求上传视频
                ddPushListener.onRequestUploadVideo(data);
            }else if(DDPushUtils.DDPUSH_LIVE_CAMERA_VIDEO.equals(code)){
                //请求时时视频流
                ddPushListener.onRequestLiveCamera(data);
            }else if(DDPushUtils.DDPUSH_LIVE_CAMERA_STOP_VIDEO.equals(code)){
                //请求停止时时视频流
                ddPushListener.onRequestStopLiveCamera();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
*/
